/*
 * @Author: taoyuqing
 * @Date: 2023-01-02 17:57:08
 * @Description: 
 */
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:spree/utils/utils.dart';
import 'package:spree/widgets/common_container.dart';
import 'package:spree/widgets/copty_input.dart';
import 'package:spree/widgets/fairness_card.dart';
import 'package:spree/widgets/vip_content_box.dart';
import 'package:spree/widgets/vip_rectangle_box.dart';

class FairnessPage extends StatefulWidget {
  FairnessPage({Key? key}) : super(key: key);

  @override
  State<FairnessPage> createState() => _FairnessPageState();
}

class _FairnessPageState extends State<FairnessPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        centerTitle: true,
        title: SvgPicture.asset('images/BETSPREELOGO.svg'),
      ),
      body: CommonContainer(
        child: ListView(
          padding: EdgeInsets.only(top: 20, bottom: 5),
          children: [
            Container(
                child: Image.asset('images/mob-banner.png'),
                margin: EdgeInsets.only(bottom: 20)),
            Column(
              children: [
                Text('HOW DOES IT WORK?',
                    style: TextStyle(
                        color: Color(0xFFFFED4A),
                        fontSize: 18,
                        fontWeight: FontWeight.w700)),
                Container(
                  child: Text(
                    'The provably fair principle is based on SHA256 technology the same as Bitcoin. The procedure of checking bets result allows you to verify the fairness of each bet.',
                    style: TextStyle(color: Colors.white),
                  ),
                  margin: EdgeInsets.only(bottom: 30, top: 10),
                ),
                FairnessCard(
                  stepNum: '01',
                  stepTitle: 'Press Fairness',
                  stepContent:
                      'Before placing a bet you may check the hash of the next round number in the "Fairness" pop-up. Hash is a random result, generated and mixed with random Server seed. Every round has its own hash. No-one knows the result before placing a bet',
                  cardTitle: 'FAIRNESS',
                  cardContent:
                      'A provably fair system based on the SHA256 algorithm and includes a random number = a combination of a random winning number and the initial number of the server. Each round has its own hash, consisting of random wins that are uniquely generated for each bet.',
                  copyContent:
                      '0e3232312313131343321657543433216575434332165754',
                ),
                Container(
                  margin: EdgeInsets.only(top: 20),
                  child: FairnessCard(
                    stepNum: '02',
                    stepTitle: 'Place a Bet',
                    stepContent:
                        'During the bet, the result is fixed in a special "Random Seed" field. By clicking "Fairness" you can find the current round hash (encrypted winning result) and history of completed bets with all the details.',
                    cardTitle: 'Lucky Number ',
                    child: Column(
                      children: [
                        Text(
                          '99',
                          style: TextStyle(
                              color: Colors.white,
                              fontSize: 32,
                              fontWeight: FontWeight.w700),
                        ),
                        Container(
                          width: Utils().getScreenWidth(context),
                          alignment: Alignment.center,
                          padding: EdgeInsets.only(top: 10, bottom: 10),
                          margin: EdgeInsets.only(bottom: 20, top: 20),
                          decoration: BoxDecoration(
                            color: Color(0xFF9165FF),
                            borderRadius:
                                BorderRadius.all(Radius.circular(10.0)),
                          ),
                          child: Text(
                            'Let’s Roll',
                            style: TextStyle(color: Colors.white),
                          ),
                        )
                      ],
                    ),
                  ),
                ),
                Container(
                  margin: EdgeInsets.only(top: 20),
                  child: FairnessCard(
                    stepNum: '03',
                    stepTitle: 'Check Hash',
                    stepContent:
                        'Click "Check". Then in the opened window paste Random Seed you\'ve copied. The issued hash below must match that fixed on BetFury.',
                    copyContent:
                        '99_3232312313131343321657543433216575434332165754',
                    child: Container(
                      width: Utils().getScreenWidth(context),
                      alignment: Alignment.center,
                      padding: EdgeInsets.only(top: 10, bottom: 10),
                      margin: EdgeInsets.only(bottom: 20),
                      decoration: BoxDecoration(
                        color: Color(0xFF9165FF),
                        borderRadius: BorderRadius.all(Radius.circular(10.0)),
                      ),
                      child: Text(
                        'Check',
                        style: TextStyle(color: Colors.white),
                      ),
                    ),
                  ),
                ),
                Container(
                  width: 120,
                  alignment: Alignment.center,
                  padding: EdgeInsets.only(top: 10, bottom: 10),
                  margin: EdgeInsets.only(bottom: 20, top: 20),
                  decoration: BoxDecoration(
                    color: Color(0xFF9165FF),
                    borderRadius: BorderRadius.all(Radius.circular(10.0)),
                  ),
                  child: Text(
                    'Play Now',
                    style: TextStyle(color: Colors.white),
                  ),
                )
              ],
            ),
            Container(
              padding: EdgeInsets.only(left: 15),
              child: Text('Frequently Asked Questions',
                  style: TextStyle(
                      color: Color(0xFFFFED4A),
                      fontSize: 18,
                      fontWeight: FontWeight.w700)),
            ),
            _createExpansionTile(
                title: 'What is a Server Seed ?',
                content:
                    'Server Seed is a random sequence of 64 symbols (numbers and letters) generated by a server.'),
            _createExpansionTile(
                title: 'What is a Random Seed ?',
                content:
                    'Random seed is a combination of Random winning number and Server seed.'),
            _createExpansionTile(
                title: 'What is a Hash Round?',
                content:
                    'It’s a specific formula for turning a piece of digital data like a paragraph of text or a file, into a line of characters called a hash of the data.'),
            _createExpansionTile(
                title: 'How does hashing proceed?',
                content:
                    'The provably fair system on BetFury is based on the SHA256 algorithm and consists of Random seed. Every round has its own hash that consists of Random winning uniquely generated for every bet.'),
            _createExpansionTile(
                title: 'When is the random number generated?',
                content:
                    'Random Lucky result is generated and mixed with random Server seed for every bet. You may see the Hash round before you make a bet in the Fairness section.'),
            _createExpansionTile(
                title: 'Why SHA-256?',
                content:
                    'Presently SHA-256 is the most secure hashing function. This function expresses the possible combinations or values that result from the given input data. Using the SHA-256 function makes it (nearly) impossible to duplicate a hash because there are just too many combinations to try and process.'),
          ],
        ),
      ),
    );
  }

  Widget _createExpansionTile(
      {required String title, required String content}) {
    return ExpansionTile(
      collapsedIconColor: Colors.white,
      iconColor: Colors.white,
      title: Text(
        title,
        style: TextStyle(color: Colors.white),
      ),
      children: [
        Text(
          content,
          style: TextStyle(color: Colors.white),
        )
      ],
    );
  }
}
